home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / gle / turboscr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-29  |  3.3 KB  |  190 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <assert.h>
  6. #include <conio.h>
  7. #include <bios.h>
  8. #include <signal.h>
  9. #include <float.h>
  10.  
  11. #define false 0
  12. #define true (!false)
  13.  
  14. #define BCOLOR BLUE
  15. #define FCOLOR MAGENTA
  16. #define HBCOLOR h_bcolor
  17. #define HVCOLOR h_fcolor
  18. #define VCOLOR WHITE
  19.  
  20. extern int h_bcolor;
  21. extern int h_fcolor;
  22. extern int noscreenio;
  23.  
  24. int gle_abort(char *s);
  25. int graphmode(void);
  26. int hpgl_initstr(void);
  27.  
  28. scr_refresh()
  29. {
  30. }
  31. int scr_getch()
  32. {
  33. }
  34. void exitcode(int i,int j);
  35. void exitcode_c(int i,int j);
  36. void exitcodef(int i,int j);
  37. scr_init()
  38. {
  39.     signal(SIGFPE,exitcodef);
  40.  
  41.     signal(SIGABRT,exitcode);
  42.     signal(SIGILL,exitcode);
  43.     signal(SIGINT,exitcode_c);
  44.     signal(SIGSEGV,exitcode);
  45.     signal(SIGTERM,exitcode);
  46. }
  47. int d_tidyup(void);
  48. extern int abort_flag;
  49. void exitcode_c(int i, int j)
  50. {
  51.     static char etxt[60];
  52.     printf("Abort key\n");
  53.     abort_flag = true;
  54.     signal(SIGINT,exitcode_c);
  55. }
  56. abort_key(void)
  57. {
  58.     int c;
  59.     if (abort_flag) return true;
  60.     if (kbhit()) {
  61.         c = bioskey(1);
  62.         c = c & 0xff;
  63.         if (c==27) {getch(); abort_flag = true; return true;}
  64.     }
  65.     return false;
  66. }
  67. void exitcode(int i, int j)
  68. {
  69.     static char etxt[60];
  70.     d_tidyup();
  71.     sprintf(etxt,"Exit handler called %d %d \n",i,j);
  72.     gle_abort(etxt);
  73. }
  74. void exitcodef(int i, int j)
  75. {
  76.     d_tidyup();
  77.     printf("Floating point error %d %d \n",i,j);
  78.     if (j==FPE_ZERODIVIDE) gle_abort("Divide by zero \n");
  79.     if (j==FPE_INTDIV0) gle_abort("Interger Divide by zero \n");
  80.     if (j==FPE_OVERFLOW) gle_abort("Numeric overflow \n");
  81.     gle_abort("Floating point Exit handler called");
  82. }
  83. scr_end()
  84. {
  85. }
  86. struct text_info r;
  87. void *screensave;
  88. screen_save()
  89. {
  90.     if (noscreenio) return;
  91.     gettextinfo(&r);
  92.     screensave = malloc(25*80*2);
  93.     if (screensave==NULL) return;
  94.     gettext(1,1,80,25,screensave);
  95. }
  96. screen_restore()
  97. {
  98.     if (noscreenio) return;
  99.     if (screensave==NULL) return;
  100.     puttext(1,1,80,25,screensave);
  101.     free(screensave);
  102.     screensave = NULL;
  103.     textattr(r.attribute);
  104.     window(r.winleft,r.wintop,r.winright,r.winbottom);
  105.     gotoxy(r.curx,r.cury);
  106. }
  107. scr_savexy()
  108. {
  109.     if (noscreenio) return;
  110.     gettextinfo(&r);
  111. }
  112. scr_left(int i)
  113. {
  114.     if (noscreenio) return;
  115.     gotoxy(wherex()-i,wherey());
  116. }
  117. scr_right(int i)
  118. {
  119.     if (noscreenio) return;
  120.     gotoxy(wherex()+i,wherey());
  121. }
  122. scr_restorexy()
  123. {
  124.     if (noscreenio) return;
  125.     textattr(r.attribute);
  126.     window(r.winleft,r.wintop,r.winright,r.winbottom);
  127.     gotoxy(r.curx,r.cury);
  128. }
  129. scr_gets(char *x)
  130. {
  131.     gets(x);
  132. }
  133.  
  134. extern int scr_blackwhite;
  135. scr_norm()  /* yellow on blue */
  136. {
  137.     if (noscreenio) return;
  138.     if (scr_blackwhite) {
  139.         textcolor(WHITE); textbackground(BLACK);
  140.     } else {
  141.         textcolor(YELLOW); textbackground(BLUE);
  142.     }
  143. }
  144. int scr_grey(void);
  145. scr_menuhi()
  146. {
  147.     if (noscreenio) return;
  148.     scr_grey();
  149. }
  150. scr_menuval()
  151. {
  152.     if (noscreenio) return;
  153.     textcolor(WHITE); textbackground(BLUE);
  154. }
  155. scr_menubg()
  156. {
  157.     if (noscreenio) return;
  158.     textcolor(YELLOW); textbackground(BLUE);
  159. }
  160. scr_inv()   /* black on white */
  161. {
  162.     if (noscreenio) return;
  163.     textcolor(WHITE); textbackground(BLACK);
  164. }
  165. scr_grey()  /* black on grey */
  166. {
  167.     if (noscreenio) return;
  168.     textcolor(BLACK); textbackground(LIGHTGRAY);
  169. }
  170. scr_isblackwhite()
  171. {
  172.     char *s;
  173.     s = getenv("CGLE_BLACKWHITE");
  174.     if (s!=NULL) return true;
  175.     else return false;
  176. }
  177. vax_edt(char *s)
  178. {
  179. }
  180. char *getsymbol(char *s)
  181. {
  182.     static char ss[100];
  183.     ss[0] = 0;
  184.     if ( getenv(s) != NULL) strcpy(ss,getenv(s));
  185.     return ss;
  186. }
  187.  
  188.  
  189.  
  190.